package cgb2202.recruitment01.entity;

import java.util.Objects;

public class CurrentUserDTO implements CurrentUser {
    Integer id;
    String email;
    String password;
    Integer userType;

    public CurrentUserDTO() {
    }

    public CurrentUserDTO(CurrentUser cu) {
        this.id = cu.getId();
        this.email = cu.getEmail();
        this.password = cu.getPassword();
        if (cu instanceof Emp) {
            this.userType = 1;
        } else if (cu instanceof Com) {
            this.userType = 2;
        } else if (cu instanceof Admin) {
            this.userType = 3;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CurrentUserDTO that = (CurrentUserDTO) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(email, that.email) &&
                Objects.equals(password, that.password) &&
                Objects.equals(userType, that.userType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, email, password, userType);
    }

    @Override
    public String toString() {
        return "currentUserDTO{" +
                "id=" + id +
                ", email='" + email + '\'' +
                ", password='" + password + '\'' +
                ", userType=" + userType +
                '}';
    }

    @Override
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Override
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getUserType() {
        return userType;
    }

    public void setUserType(Integer userType) {
        this.userType = userType;
    }
}
